home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / SAT 2.3b4 / Demo ƒ / Collision demo ƒ / Collision.p < prev    next >
Encoding:
Text File  |  1995-01-29  |  1.4 KB  |  53 lines  |  [TEXT/PJMM]

  1. {*****************************}
  2. {********* SAT Collision **********}
  3. {*****************************}
  4.  
  5. {A SAT demo that is slightly over SATminimal, demonstrating the simplest}
  6. {collision handling based on the kind field (KindCollision).}
  7.  
  8. program SATcollision;
  9.  
  10.     uses
  11. {$ifc UNDEFINED THINK_PASCAL}
  12.         Types, QuickDraw, Events, Windows, Dialogs, Fonts, DiskInit, TextEdit, Traps, Desk, Memory, SegLoad, Scrap, ToolUtils, OSEvents, OSUtils, Menus, Resources, StandardFile, GestaltEqu, Files, Errors, 
  13. {$endc}
  14.         SAT, sMrEgghead, sApple;
  15.  
  16.     var
  17.         ignoreSp: SpritePtr;
  18.         l: longint;
  19.         p: Point;
  20. begin
  21. {Standard Inits are done by Think Pascal.}
  22. {$IFC UNDEFINED THINK_PASCAL}
  23.     SATInitToolbox;
  24. {$ENDC}
  25.  
  26. {Initialize SAT}
  27.     SATConfigure(true, kVPositionSort, kKindCollision, 32);
  28.     SATInit(128, 129, 512, 322);
  29.  
  30. {Initialize sprite units}
  31.     InitMrEgghead;
  32.     InitApple;
  33.  
  34. {Make sprites}
  35.     GetMouse(p); {We get the mouse position in order to put Mr Egghead under it immediately}
  36.     ignoreSp := SATNewSprite(0, p.h, p.v, @SetupMrEgghead);
  37.     ignoreSp := SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), @SetupApple);
  38.  
  39.     HideCursor;
  40.  
  41.     repeat
  42.         l := TickCount;
  43.         SATRun(true); {Run a frame of animation}
  44.         while l > TickCount - 3 do {Speed limit}
  45.             ;
  46.  
  47. {Start a new apple once in a while}
  48.         if SATRand(40) = 1 then
  49.             ignoreSp := SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), @SetupApple);
  50.     until Button;
  51.     ShowCursor;
  52.     SATSoundShutUp; {Always make sure the sound channel is de-allocated!}
  53. end.